package com.example.nep.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.nep.model.Aqi;
import com.example.nep.dao.AqiMapper;
import com.example.nep.service.IAqiService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author han
 * @since 2024-04-10
 */
@Service
public class AqiServiceImpl extends ServiceImpl<AqiMapper, Aqi> implements IAqiService {
//    原符号       <       <=      >       >=      <>
//    对应函数    lt()     le()    gt()    ge()    ne()
    @Override
    public Aqi findAqi(Integer type, Integer value) {
        LambdaQueryWrapper<Aqi> wrapper=new LambdaQueryWrapper<>();
        if (type==1){
            //so2
            wrapper.ge(Aqi::getSo2Max,value)
                    .le(Aqi::getSo2Min,value);
        } else if (type==2) {
            //co
            wrapper.ge(Aqi::getCoMax,value)
                    .le(Aqi::getCoMin,value);
        }else if (type==3){
            //spm
            wrapper.ge(Aqi::getSpmMax,value)
                    .le(Aqi::getSpmMin,value);
        }
        Aqi aqi = getOne(wrapper);
        return aqi;
    }
}
